package com.hxzy.controller.cellinfo;

import com.alibaba.fastjson.JSONObject;
import com.hxzy.common.BaseServlet;
import com.hxzy.common.ResultAjax;
import com.hxzy.entity.Cellinfo;
import com.hxzy.service.cellinfoService;
import com.hxzy.service.impl.cellinfoSerxiceIpml;
import com.hxzy.util.StringUtil;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Description:
 * @Author: ykj
 * @Date: 2022/3/10 19:42
 */
@WebServlet(urlPatterns = "/cellInfo/findOne")
public class CellInfoFindOne extends BaseServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String id = req.getParameter("id");
        if (StringUtil.isBlank(id)){
            ResultAjax error = ResultAjax.error("非提供参数,不允许操作");
            super.render(resp, JSONObject.toJSONString(error));
            return;
        }

        //查询数据库
        cellinfoService service=new cellinfoSerxiceIpml();
        Cellinfo cellinfo = service.findOne(id);
        if (cellinfo==null){
            ResultAjax error = ResultAjax.error("参数值不确定");
            super.render(resp, JSONObject.toJSONString(error));
            return;
        }

        //输出给前段
        ResultAjax resultAjax = ResultAjax.succss_data(cellinfo);
        super.render(resp, JSONObject.toJSONString(resultAjax));

    }
}
